﻿@using Bootstrap.Controllers
@model ILookup<string, SettingValueViewModel>
<form method="POST">
    @Html.AntiForgeryTokenOrchard()
    <div>
        <button type="submit">Save</button>
    </div>
    <div>
        <h3>Settings</h3>
        @foreach (var category in Model) {
        <div style="margin-left: 1.7em; min-width: 300px;">
            <fieldset>
                <legend>@category.Key</legend>
                @foreach (var setting in category) 
                {
                    <div>
                    @if (setting.IsSwitch) {
                        bool check = false;
                                               bool.TryParse(setting.Value, out check);
                        
                        <span>@(setting.DisplayName) :</span>
                        @Html.CheckBox(setting.Name, check);
                        

                    }
                    else if (setting.HasChoices)
                    {   
                        <label>@(setting.DisplayName) :</label>
                        @Html.DropDownList(setting.Name, setting.Choices.Select(x => new SelectListItem() { Text = x, Value = x, Selected = x == setting.Value }));
                    }
                    else
                    {
                        <label>@(setting.DisplayName) :</label>
                        @Html.TextBox(setting.Name, setting.Value, new { Size = 25 });
                    }
                    </div>                        
                }
            </fieldset>
        </div>
        
        }
    </div>
</form>